#
# Makefile for build using GNU C++(Unified for all Unix)
# The autoconf will not change this file
# The adaption is done by changing ../../config/unix/Make.defines
#
# all:       build tetris core
# clean:     clean tetris core
#
##############################################################################
#

TETRIS_CORE_SRCDIR	= .
TETRIS_CORE_HDIR	= $(TETRIS_CORE_SRCDIR)/../h
TETRIS_CORE_BINDIR	= $(TETRIS_CORE_SRCDIR)/../bin
TETRIS_CORE_INTDIR 	= $(TETRIS_CORE_SRCDIR)/../obj

TETRIS_CORE_OBJS	= \
			$(TETRIS_CORE_INTDIR)/main.o \
			$(TETRIS_CORE_INTDIR)/lnx_console_ui.o
#            $(TETRIS_CORE_INTDIR)/dmd.o \
#            $(TETRIS_CORE_INTDIR)/tetris.o \
#            $(TETRIS_CORE_INTDIR)/lnx_console_ui.o \
#            $(TETRIS_CORE_INTDIR)/main.o
 
TETRIS_CORE_TARGET  = $(TETRIS_CORE_BINDIR)/tetris_core 

#
##############################################################################
#

BOOST_HOME		= /root/boost_1_47_0/centos
BOOST_INCLUDE	= $(BOOST_HOME)/include
BOOST_LIBS		= $(BOOST_HOME)/lib

INCLUDE_OPTIONS	= -I$(TETRIS_CORE_HDIR) -I$(BOOST_INCLUDE)
LINK_OPTIONS	= -ldl -lrt -Bstatic $(BOOST_LIBS)/libboost_thread.a
#LINK_OPTIONS	= -ldl -lrt -lpthread
#LINK_OPTIONS	= -ldl -lrt -lpthread -L$(BOOST_LIBS) -B -static $(BOOST_LIBS)/libboost_thread.a
CXXFLAGS		= -DLINUX -DCENTOS -g

TETRIS_CORE_CXXFLAGS	= $(CXXFLAGS) $(INCLUDE_OPTIONS) -DUNIX

#
##############################################################################
#

all: core

core: checkbindir checkintdir $(TETRIS_CORE_TARGET)

$(TETRIS_CORE_TARGET) : $(TETRIS_CORE_OBJS) $(TETRIS_CORE_HDIR) 
	$(CXX) $(TETRIS_CORE_CXXFLAGS) -o $@ $(TETRIS_CORE_OBJS) $(LINK_OPTIONS) 

checkbindir:
	@if test ! -d $(TETRIS_CORE_BINDIR) ; \
	then \
		mkdir $(TETRIS_CORE_BINDIR) ; \
	fi
	
checkintdir:
	@if test ! -d $(TETRIS_CORE_INTDIR) ; \
	then \
		mkdir $(TETRIS_CORE_INTDIR) ; \
	fi

clean: cleantetriscore

cleantetriscore:
	rm -f -r $(TETRIS_CORE_INTDIR)
	rm -f $(TETRIS_CORE_TARGET)
	
#
# server sslgw files
#

$(TETRIS_CORE_INTDIR)/dmd.o:
	$(CXX) $(TETRIS_CORE_CXXFLAGS) $(INCLUDE_OPTIONS) -c -o $@ $(TETRIS_CORE_SRCDIR)/dmd.cpp

$(TETRIS_CORE_INTDIR)/tetris.o:
	$(CXX) $(TETRIS_CORE_CXXFLAGS) $(INCLUDE_OPTIONS) -c -o $@ $(TETRIS_CORE_SRCDIR)/tetris.cpp

$(TETRIS_CORE_INTDIR)/lnx_console_ui.o:
	$(CXX) $(TETRIS_CORE_CXXFLAGS) $(INCLUDE_OPTIONS) -c -o $@ $(TETRIS_CORE_SRCDIR)/lnx_console_ui.cpp

$(TETRIS_CORE_INTDIR)/main.o:
	$(CXX) $(TETRIS_CORE_CXXFLAGS) $(INCLUDE_OPTIONS) -c -o $@ $(TETRIS_CORE_SRCDIR)/main.cpp
